package com.atwork.service.impl;

import com.atwork.dao.SysDeptDao;
import com.atwork.model.normal.SysDept;
import com.atwork.service.SysDeptService;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @CreateBy: zhaojun
 * @CreateTime: 2018-08-04
 * @Desc: 系统部门模块
 */
@Service
@Slf4j
public class SysDeptServiceImpl implements SysDeptService {
    @Autowired
    private SysDeptDao sysDeptDao;
    @Override
    public List<SysDept> getAllDept(int pageNum, int pageSize) {
        log.info("获取全部部门信息");
        PageHelper.startPage(pageNum,pageSize);
        return sysDeptDao.getAllDept();
    }

    @Override
    public int insertDept(SysDept record) {
        log.info("添加部门信息");
        return sysDeptDao.insertDept(record);
    }

    @Override
    public SysDept getDeptById(Integer id) {
        log.info("通过id获取部门信息");
        return sysDeptDao.getDeptById(id);
    }

    @Override
    public int updateDeptById(SysDept record) {
        log.info("更新部门信息");
        return sysDeptDao.updateDeptById(record);
    }

    @Override
    public List<SysDept> getDeptByUserId(Integer userId) {
        log.info("通过用户id获取部门信息");
        return sysDeptDao.getDeptByUserId(userId);
    }
}
